#include <bits/stdc++.h>
using namespace std;

class Solution
{
public:
    void solve(vector<int> &nums, int &ans, int pos, int sum, int target)
    {
        if (pos >= nums.size())
        {
            if (sum == target)
            {
                ans++;
            }
            return;
        }

        for (int i = 0; i < 2; ++i)
        {
            if (i == 0)
            {
                solve(nums, ans, pos + 1, sum + nums[pos], target);
            }
            else
            {

                solve(nums, ans, pos + 1, sum - nums[pos], target);
            }
        }
    }
    int findTargetSumWays(vector<int> &nums, int target)
    {
        int ans = 0;
        solve(nums, ans, 0, 0, target);
        return ans;
    }
};